package com.jqr.activity.myfirstdemo

import android.app.Notification
import android.os.Bundle
import android.view.textclassifier.ConversationActions

import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.MutatePriority
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.text.ClickableText
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable

import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.jqr.activity.myfirstdemo.ui.theme.MyFirstDemoTheme
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.unit.dp
import androidx.core.app.NotificationCompat


class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            MyFirstDemoTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {
                    Greeting()
                }
            }
        }
    }
}
@Composable
fun conversationScreen(){
    val scope= rememberCoroutineScope()
    var lazyListState= rememberLazyListState()



}



@Composable
fun Greeting() {
    var name by rememberSaveable {
        mutableStateOf("")
    }
    HelloContent(name = name, onNameChange = {name=it})
    val message=Message("click me",1234)
    
    chatBubble(message = message)

}

@Composable
fun  HelloContent(name:String,onNameChange:(String)->Unit){
    Column (modifier = Modifier.padding(16.dp)){
        Text(
            text = "Hello $name",
            modifier = Modifier.padding(bottom = 1.dp),
        )
        OutlinedTextField(value = name, onValueChange = onNameChange, label = { Text(text = "name")})

    }
}
@Composable
fun  chatBubble( message: Message){

    var showDetail by remember {
        mutableStateOf(false)
    }
    Column(modifier =Modifier.padding(16.dp)) {
        ClickableText(text = AnnotatedString(message.content), onClick ={showDetail=!showDetail} )

        if (showDetail){
            Text(text = message.timestamp.toString())
        }
    }


}



data class  Message(val content:String,val timestamp:Int);

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
    MyFirstDemoTheme {
        Greeting()
    }
}